// Generic Node bootstrapper to run a TypeScript file via ts-node's require hook.
// Usage: node run-ts.js [relative/path/to/file.ts]
// If no file is provided, defaults to '2.抽象工厂.ts'.
const path = require('path');
const fs = require('fs');

const fileArg = process.argv[2] || '2.抽象工厂.ts';
const entry = path.resolve(__dirname, fileArg);

if (!fs.existsSync(entry)) {
  console.error(`文件不存在: ${entry}`);
  process.exit(2);
}

require('ts-node').register({
  transpileOnly: true,
  compilerOptions: { module: 'commonjs' }
});

// Require the TypeScript entry (absolute path). ts-node will handle .ts.
require(entry);
